package com.smzd.ccms.domain;

import java.util.HashMap;
import java.util.Map;

import com.smzd.core.domain.BaseOwnedEntity;
import com.smzd.framework.annotation.ModuleGroup;
import com.smzd.framework.system.domain.Meeting;

@ModuleGroup(value = "ccms/admin", moduleNames = "sites", moduleName = "site")
public class Site extends BaseOwnedEntity<Meeting> {
	private static final long serialVersionUID = -9090145069694321462L;
	public static final String SESSION_KEY_CURRENT_SITE = "_current_site";
	// domain
	private String domain;
	// icp
	private String icp;
	// path
	private String path;

	private Map<String, Channel> channels;

	public Map<String, Channel> getChannels() {
		return channels;
	}

	public void setChannels(Map<String, Channel> channels) {
		this.channels = channels;
	}

	public void addChannel(Channel channel) {
		if (channels == null) {
			synchronized (this) {
				if (channels == null) {
					channels = new HashMap<>();
				}
			}
		}
		channels.put(channel.getPath(), channel);
	}

	public Channel getChannel(String channelStr) {
		if (channels == null || channels.size() == 0) {
			return null;
		}
		return channels.get(channelStr);
	}

	public Channel getChannel(Integer chId) {
		for(Channel ch : channels.values()){
			if(ch.getId()-chId==0){
				return ch;
			}
		}
	    return null;
    }

	/**
	 * 获取domain
	 * 
	 * @return
	 */
	public String getDomain() {
		return domain;
	}

	/**
	 * 设置domain
	 * 
	 * @param domain
	 */
	public void setDomain(String domain) {
		this.domain = domain;
	}

	/**
	 * 获取icp
	 * 
	 * @return
	 */
	public String getIcp() {
		return icp;
	}

	/**
	 * 设置icp
	 * 
	 * @param icp
	 */
	public void setIcp(String icp) {
		this.icp = icp;
	}

	/**
	 * 获取path
	 * 
	 * @return
	 */
	public String getPath() {
		return path;
	}

	/**
	 * 设置path
	 * 
	 * @param path
	 */
	public void setPath(String path) {
		this.path = path;
	}
}